https://git.oschina.net/780391630/testone.gitpackage com.cmcc.es.app.service.impl;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Base64Utils;

import cc.movein.common.utils.XmlTools;

import com.cmcc.es.app.mapper.AgentSyncMapper;
import com.cmcc.es.app.model.AgentInfo;
import com.cmcc.es.app.model.AgentSyncData;
import com.cmcc.es.app.service.DataSyncService;

/**
 * 锟叫憋拷锟斤拷锟酵拷锟斤拷锟斤拷锟绞碉拷锟�
 * 
 *agentSyncService
 */
@Service("agentSyncService")
public class AgentSyncServiceImpl implements DataSyncService{

	

    private Log log = LogFactory.getLog(AgentSyncServiceImpl.class);
    private static final String DATA_FORMAT = "yyyy-MM-dd HH:mm:ss";
    @Autowired
    private AgentSyncMapper agentSyncMapper;

    @Transactional
    @Override
    public void doSync(String xml) {
        String decodedXml = null;
        try {
            decodedXml = new String(Base64Utils.decodeFromString(xml), "utf-8");
            log.debug(decodedXml);
            AgentSyncData data = XmlTools.xmlStringToBean(decodedXml, AgentSyncData.class, DATA_FORMAT);
            log.info(data);
            List<AgentInfo> updateList = data.getUpdateList();
            List<AgentInfo> insertList = data.getInsertList();
            if (updateList != null && updateList.size() > 0) {
                
                agentSyncMapper.updateList(updateList);
            
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finadsadsadsadsdsadsadasad
>>>>>>> a10b383c497bb3843e305024dd7e79fd99bf54fe
    }
}
